<!-- 调用头部文件 -->
<include file = "Public:header_content" title = "{$title}" />
<div class="main-content">
    <div class="apisys-content">
        <div class="apisys-content-title">
            <h3>
                <a href="javascript:window.location.reload();" title="刷新本页"><i class="fa fa-refresh"></i></a> 添加API接口
            </h3>
        </div>
        <div class="apisys-content-content form-body">

                <form id="form" action="{$post_action}" method="post" class="form-horizontal">


                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m" >
                                <h5 class="p-xxs m-l-sm">接口名称 <i class="fa fa-asterisk text-danger"></i></h5>
                            </span>
                            <input type="text" class="form-control" id="title" name="title" value=""
                                   placeholder="接口名称">
                        </div>
                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m" >
                                <h5 class="p-xxs m-l-sm">接口描述 <i class="fa fa-asterisk text-danger"></i></h5>
                            </span>
                            <input type="text" class="form-control" id="description" name="description" value=""
                                   placeholder="接口描述">
                        </div>
                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m" >
                                <h5 class="p-xxs m-l-sm">关键词</h5>
                            </span>
                            <input type="text" class="form-control" id="keywords" name="keywords" value=""
                                   placeholder="关键词">
                        </div>
                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m" >
                                <h5 class="p-xxs m-l-sm">项目分类 <i class="fa fa-asterisk text-danger"></i></h5>
                            </span> </span>
                            <select id="project_id" name="project_id" class="form-control "   >
                                <option value="0">项目分类</option>
                                <volist name="catlist" id="vo">
                                    <option value="{$vo['id']}">{$vo.spacer}{$vo.name}</option>
                                </volist>
                            </select>
                        </div>

                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m" >
                                <h5 class="p-xxs m-l-sm">接口地址 <i class="fa fa-asterisk text-danger"></i></h5>
                            </span>
                            <span class="input-group-btn" >
                               <h5 class="p-xxs m-l-sm" id="url_str"></h5>
                            </span><input type="text" class="form-control" style="ime-mode:disabled;" id="apiurl" name="apiurl" value=""
                                   placeholder="接口地址">
                        </div>
                        <div class="input-group m-b">
                                <span class="input-group-btn btn-w-m" >
                                    <h5 class="p-xxs m-l-sm">method <i class="fa fa-asterisk text-danger"></i></h5>
                                </span>
                            <select id="method" name="method" class="form-control "  style="width: 150px;" >
                                <option value="GET">GET</option>
                                <option value="POST">POST</option>
                                <option value="DELETE">DELETE</option>
                                <option value="PUT">PUT</option>
                            </select>
                        </div>
                        <div class="input-group m-b">
                       <span class="input-group-btn btn-w-m" style="vertical-align:top;">
                                <h5 class="p-xxs m-l-sm">请求字段 <i class="fa fa-asterisk text-danger"></i></h5>
                       </span>
                            <button type="button" class="btn btn-primary m-l-sm"  id="add-request-btn">  添加请求参数  <i class="fa fa-plus"></i></button>



                            <div class="input-group">
                                <div id="add-request-list">
                                </div>
                            </div>


                        </div>
                        <div class="input-group m-b">
                       <span class="input-group-btn btn-w-m" style="vertical-align:top;">
                                <h5 class="p-xxs m-l-sm">返回字段 <i class="fa fa-asterisk text-danger"></i></h5>
                       </span>
                            <button type="button" class="btn btn-primary m-l-sm"  id="add-response-btn">  添加返回字段  <i class="fa fa-plus"></i></button>



                            <div class="input-group">
                                <div id="add-response-list">
                                </div>
                            </div>


                        </div>
                        <div class="input-group m-b">
                            <span class="input-group-btn btn-w-m " style="vertical-align:top;">
                                <h5 class="p-xxs m-l-sm">返回参数 <i class="fa fa-asterisk text-danger"></i></h5>
                            </span>

                            <textarea class="form-control" id="restring" name="restring" placeholder="返回参数" ></textarea>
                        </div>
                        <div class="input-group m-b">

                            <span class="input-group-btn btn-w-m " style="vertical-align:top;">
                                <h5 class="p-xxs m-l-sm">备   注</h5>
                            </span>
                            <textarea class="form-control" id="memo" name="memo" placeholder="备注" ></textarea>
                        </div>


                        <div style="text-align: center;">
                            <button type="submit" class="btn btn-primary m-l-sm" ><i class="fa fa-save"></i> 提交保存</button>
                            <button type="reset" class="btn btn-primary m-l-sm" ><i class="fa fa-remove"></i> 重置</button>
                        </div>

       



                </form>
                <!-------->
                <div class="input-inline margin-top add-request-input hidden">
                    <input class="form-control " name="request[key_name][]" style="width: 100px;ime-mode:disabled;" size="20" placeholder="参数名" type="text">
                    <select name="request[key_type][]" class="form-control" style="width: 110px;">
                        <option value="">数据类型</option>
                        <option value="int">int</option>
                        <option value="string" selected="selected">string</option>
                        <option value="float">float</option>
                        <option value="file">file</option>
                        <option value="boolen">boolen</option>
                        <option value="array">array</option>
                        <option value="object">object</option>
                    </select>
                    <select name="request[key_must][]" class="form-control" style="width: 80px;">
                        <option value="1">必传</option>
                        <option value="0">选传</option>
                    </select>
                    <input name="request[key_description][]"  class="form-control" style="width: 215px;" size="45" placeholder="参数描述" type="text">
                    <input name="request[key_value][]"  class="form-control" style="width: 120px;" size="100" placeholder="参数值(可选)" type="text">
                    &nbsp;<button type="button" class="btn btn-danger add-request-remove"><i class="fa fa-remove  text-nowrap"></i></button>
                </div>
                <!---返回zhi--->
                <div class="input-inline margin-top add-response-input hidden">
                    <input class="form-control " name="response[key_name][]" style="width: 100px;ime-mode:disabled;" size="20" placeholder="参数名" type="text">
                    <select name="response[key_type][]" class="form-control" style="width: 110px;">
                        <option value="{$data['id']}">数据类型</option>
                        <option value="int">int</option>
                        <option value="string" selected="selected">string</option>
                        <option value="float">float</option>
                        <option value="file">file</option>
                        <option value="boolen">boolen</option>
                        <option value="array">array</option>
                        <option value="object">object</option>
                    </select>
                    <input name="response[key_description][]"  class="form-control" style="width: 215px;" size="45" placeholder="参数描述" type="text">
                    &nbsp;<button type="button" class="btn btn-danger add-response-remove"><i class="fa fa-remove  text-nowrap"></i></button>
                </div>
                <!-------->
            </div>

    </div>
</div>


<!-- 调用脚本文件 -->
<include file = "Public:script"  />
<script type="text/javascript">

     $(function () {
         $("#project_id").change(function () {
             var parject_id = $("#project_id").val();
             var url = "/index.php?s=/Docapi/Opapi/catUrl/cid/" + parject_id + ".html";  //"{:U('Docapi/Opapi/catUrl?cid=4')}";
             $.ajax({
                 type: "get",
                 url: url,
                 dataType: "json",
                 success: function (data) {
                     if (data.status == 1) {
                         $("#url_str").html(data.catUrl);
                     }
                 }
             });
         });

     });

</script>
<script>
    $(document).ready(function () {

        //request
        //添加
        $("#add-request-btn").bind('click', function(event) {
            //alert('hdshfdsf');
            $("#add-request-list").append($(".add-request-input.hidden").clone());
            $("#add-request-list .add-request-input").last().removeClass('hidden');
        });
        //删除
        $("#add-request-list").on("click",".add-request-remove",function(event) {
            $(this).parent(".add-request-input").remove();
        });
        //response
        //添加
        $("#add-response-btn").bind('click', function(event) {
            //alert('hdshfdsf');
            $("#add-response-list").append($(".add-response-input.hidden").clone());
            $("#add-response-list .add-response-input").last().removeClass('hidden');
        });
        //删除
        $("#add-response-list").on("click",".add-response-remove",function(event) {
            $(this).parent(".add-response-input").remove();
        });

    });
</script>
<!-- 调用脚部文件 -->
<include file = "Public:footer_content"  />
